package com.lrkj.payfee.controller;

import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.payfee.domain.ReceiptRecord;
import com.lrkj.payfee.domain.vo.ReceiptRecordVo;
import com.lrkj.payfee.service.IReceiptRecordService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 收款单明细记录Controller
 *
 * @author yajun_ren
 * @date 2021-08-16
 */
@RestController
@RequestMapping("/payfee/receiptRecord")
public class ReceiptRecordController extends BaseController {
    @Autowired
    private IReceiptRecordService receiptRecordService;

    /**
     * 查询收款单明细记录列表
     */
    @ApiOperation(value = "查询收款单明细记录列表", notes = "查询收款单明细记录列表")
    @GetMapping("/list")
    public TableDataInfo list(ReceiptRecord receiptRecord) {
        startPage();
        List<ReceiptRecordVo> list = receiptRecordService.selectRecordRuleCostList(receiptRecord);
        return getDataTable(list);
    }

    /**
     * 导出收款单明细记录列表
     */
    @ApiOperation(value = "导出收款单明细记录列表", notes = "导出收款单明细记录列表")
    @PreAuthorize("@ss.hasPermi('payfee:receiptRecord:export')")
    @Log(title = "收款单明细记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ReceiptRecord receiptRecord) {
        List<ReceiptRecordVo> list = receiptRecordService.selectRecordRuleCostList(receiptRecord);
        ExcelUtil<ReceiptRecordVo> util = new ExcelUtil<ReceiptRecordVo>(ReceiptRecordVo.class);
        return util.exportExcel(list, "收款单明细记录数据");
    }

    /**
     * 获取收款单明细记录详细信息
     */
    @ApiOperation(value = "获取收款单明细记录详细信息", notes = "获取收款单明细记录详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:receiptRecord:query')")
    @GetMapping(value = "/{receiptRecordId}")
    public AjaxResult getInfo(@PathVariable("receiptRecordId") String receiptRecordId) {
        return AjaxResult.success(receiptRecordService.selectReceiptRecordById(receiptRecordId));
    }

}
